$(function () {
  var loginTitle = $('#loginTitle');
  var registertTitle = $('#registertTitle');
  var logincont = $('#logincont');
  var registerCont = $('#registerCont');
  var loginSpan = $('span', '.twoChecks');
  var psw = $('#psw'); //密码登录框
  var registerBtn = $('#registerBtn');

  store.clear();

  loginTitle.click(function () {
    logincont.show();
    registerCont.hide();
  });
  registertTitle.click(function () {
    logincont.hide();
    registerCont.show();
  });

  /**
   * 
   * 登陆显示隐藏
   */

  loginSpan.click(function () {
    loginSpan.removeClass('active');
    $(this).addClass('active');
  });
  loginSpan.eq(0).click(function () { //密码登录
    $('#yzcode').hide();
    psw.show();
    $('#loginYzCode').show();
  })
  loginSpan.eq(1).click(function () { //验证码登录
    $('#yzcode').show();
    psw.hide();
    $('#loginYzCode').hide();
  });


  /***** 注册弹窗 *****/

  registerBtn.click( function() {
    window._EditFrameIndex = x_admin_show('注册','./register.html');
  });


  /***** 登录跳转 ******/
  var account = $('#account');
  var pswinput = $('#pswinput');
  $('#loginBtn').click( function(){
    var accountval = $.trim(account.val());
    var pswVal = $.trim(pswinput.val());

    if( !accountval ) {
      return layer.msg('账号不能为空');
    }
    if( !pswVal ) {
      return layer.msg('密码不能为空');
    }
    

    if( accountval == 'admin' && pswVal == '123456' ) {
        store.save('user',{userName:'admin'});
        location.href = 'index.html'
    }
   
  });

  $(document).keyup(function(e){
    if(e.keyCode == 13 ) {
      $('#loginBtn').click();
    }
  })
})